package com.company.cloud.common.job.xxl;

import com.company.cloud.common.constant.ConfigConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;

@Configuration
@ConditionalOnProperty(value = ConfigConstants.CONFIG_XXL_JOB_ENABLED, havingValue = "true")
public class XxlJobConfig {

	private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);

	
	@Value("${saas.job.xxl.adminAddresses}")
	private String adminAddresses;

	@Value("${saas.job.xxl.accessToken}")
	private String accessToken;

//	@Value("${saas.job.xxl.executor.appname:#{null}}")
	@Value("${spring.application.name}")
	private String appname;

	@Value("${saas.job.xxl.executor.address:#{null}}")
	private String address;

	@Value("${saas.job.xxl.executor.ip:#{null}}")
	private String ip;

	@Value("${saas.job.xxl.executor.port}")
	private int port;

	@Value("${saas.job.xxl.executor.logpath}")
	private String logPath;

	@Value("${saas.job.xxl.executor.logretentiondays}")
	private int logRetentionDays;

//	@Bean
//	public XxlJobSpringExecutor xxlJobExecutor() {
//		logger.info("++++++ xxl-job config init.");
//		System.out.println("+++++ appname="+appname);
//		XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
//		xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
//		xxlJobSpringExecutor.setAppname(appname);
//		xxlJobSpringExecutor.setAddress(address);
//		xxlJobSpringExecutor.setIp(ip);
//		xxlJobSpringExecutor.setPort(port);
//		xxlJobSpringExecutor.setAccessToken(accessToken);
//		xxlJobSpringExecutor.setLogPath(logPath);
//		xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
//		return xxlJobSpringExecutor;
//	}

}
